package com.control;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.Student;

/**
 * Servlet implementation class ElServlet
 */
@WebServlet("/ElServlet")
public class ElServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ElServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setAttribute("name", "庄三");
		String [] s = new String[]{"1","2"};
		request.setAttribute("mys",s);
		Student stu = new Student();
		stu.setSid(1001);
		stu.setSname("Jarvis");
		request.setAttribute("mystu",stu);
		
		Student[] stus=new Student[2];
		Student stu1 = new Student();
		stu1.setSid(1001);
		stu1.setSname("Jarvis");
		Student stu2 = new Student();
		stu2.setSid(1002);
		stu2.setSname("Harvis");
		stus[0]=stu1;
		stus[1]=stu2;
		
		Map  map=new HashMap();
		map.put("address", "西安");
		
		List list = new ArrayList();
		list.add("星期一");
		list.add("星期二");
		list.add("星期三");
		list.add("星期四");
		
		List list1 = new ArrayList();
		list1.add(stu1);
		list1.add(stu2);
		request.setAttribute("mylist1", list1);
		request.setAttribute("mylist", list);
		request.setAttribute("myaddress", map);
		request.setAttribute("mystus", stus);
		request.getRequestDispatcher("testEl/testEl.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
